import os, sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from sqlist import SqList

def Merge(sq1, sq2):
    """Merge two sorted sequential lists"""
    # Create temporary list for merged result
    temp = sq1.data[:sq1.size] + sq2.data[:sq2.size]
    temp.sort()
    # Update sq1's data and size
    sq1.data = temp
    sq1.size = len(temp)
    k = 0
    for i in range(sq1.size):
        if sq1.data[i] != sq1.data[k]:
            k += 1
            sq1.data[k] = sq1.data[i]
    sq1.size = k + 1

if __name__ == "__main__":
    sq1 = SqList()
    sq1.CreateList([1, 2, 2, 3, 3, 3, 4, 5, 6, 6, 6, 7, 8, 9])
    sq2 = SqList()
    sq2.CreateList([1, 2, 2, 3, 3, 3, 4, 5, 10, 11, 12, 13, 14, 15])
    Merge(sq1,sq2)
    print(sq1.display())
